﻿package mortal.game.resource
{
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.common.swfPlayer.data.*;
    import mortal.common.swfPlayer.frames.*;

    public class FrameTypeConfig extends Object
    {
        private var _map:Dictionary;
        private var _nameMap:Dictionary;
        private static var _instance:FrameTypeConfig;

        public function FrameTypeConfig()
        {
            this._map = new Dictionary();
            this._nameMap = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" FrameTypeConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:SwfFrames = null;
            var _loc_3:ActionInfo = null;
            var _loc_4:Object = null;
            var _loc_6:Object = null;
            var _loc_5:Array = [];
            if (param1.modle is Array)
            {
                _loc_5 = param1.modle;
            }
            else
            {
                _loc_5.push(param1.modle);
            }
            for each (_loc_6 in _loc_5)
            {
                
                _loc_2 = new SwfFrames(_loc_6.frameType, _loc_6.name);
                _loc_2.createAction(_loc_6);
                this._map[_loc_2.frameType + "_" + _loc_2.type] = _loc_2;
                this._nameMap[_loc_2.name] = _loc_2;
            }
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getObjectByFileName("frameType.xml");
            this.write(_loc_1);
            return;
        }// end function

        public function getFramesByType(param1:String, param2:int = 0) : SwfFrames
        {
            return this._map[param1 + "_" + param2];
        }// end function

        public function getFramesByName(param1:String) : SwfFrames
        {
            return this._nameMap[param1];
        }// end function

        public static function get instance() : FrameTypeConfig
        {
            if (_instance == null)
            {
                _instance = new FrameTypeConfig;
            }
            return _instance;
        }// end function

    }
}
